/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hero.web.action.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 性能拦截器
 * @author Volcano
 */
public class CapabilityInterceptor extends AbstractInterceptor {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Log log=LogFactory.getLog(CapabilityInterceptor.class);
    @Override
    public String intercept(ActionInvocation ai) throws Exception {
    	if(!log.isDebugEnabled())
    	{
    		return ai.invoke();
    	}
        long startTime=System.currentTimeMillis();
        String result= ai.invoke();
        long endTime=System.currentTimeMillis();
        log.debug("action="+ai.getProxy().getActionName()+",method="+ai.getProxy().getMethod()+",执行耗时="+(endTime-startTime)+"毫秒。");
        return result;
    }
}
